package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.border.EtchedBorder;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

public class TelaSobre extends JDialog {

	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	
	private JPanel panelPrincipal;
	
	/**
	 * Create the frame.
	 */
	public TelaSobre(JFrame pai) {
		super(pai);
		this.setModal(true);
		initialize();
	}
	
	private void initialize(){
		setBackground(Color.WHITE);
		setUndecorated(true);
		setType(Type.UTILITY);
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 300, 350);
		setLocationRelativeTo(null);
		setAlwaysOnTop(true);
		contentPane = new JPanel();
		contentPane.setBackground(Color.BLACK);
		contentPane.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		panelPrincipal= new JPanel();
		panelPrincipal.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
		panelPrincipal.setForeground(Color.WHITE);
		panelPrincipal.setBackground(Color.BLACK);
		contentPane.add(panelPrincipal, BorderLayout.CENTER);
		
		JLabel lblDevCou = new JLabel("DEV C+ou-");
		lblDevCou.setHorizontalAlignment(SwingConstants.CENTER);
		lblDevCou.setFont(new Font("Comic Sans MS", Font.BOLD, 25));
		lblDevCou.setForeground(Color.WHITE);
		
		JTextPane txtpnCompiladorDesenvolvidoPara = new JTextPane();
		txtpnCompiladorDesenvolvidoPara.setBackground(Color.BLACK);
		txtpnCompiladorDesenvolvidoPara.setEditable(false);
		txtpnCompiladorDesenvolvidoPara.setEnabled(false);
		txtpnCompiladorDesenvolvidoPara.setText("Compilador desenvolvido para a Linguagem C+ou-, ambos desenvolvidos pelo aluno C\u00E9fanys de Morais Braga para obten\u00E7\u00E3o de cr\u00E9ditos na disciplina de Compiladores na Universidade Federal Rural de Pernambuco (UFRPE) - Unidade Acad\u00EAmica de Garanhuns (UAG), sob avalia\u00E7\u00E3o da Prof\u00AA. Msc. Maria Aparecida Amorim Sibaldo. Garanhuns-PE (2014.1)\r\n");
		StyledDocument doc = txtpnCompiladorDesenvolvidoPara.getStyledDocument();  
		  
        MutableAttributeSet standard = new SimpleAttributeSet();  
        StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER);  
        doc.setParagraphAttributes(0, 0, standard, true);
		
		JButton botaoOK = new JButton("OK :-)");
		botaoOK.setHorizontalTextPosition(SwingConstants.CENTER);
		botaoOK.setBorderPainted(false);
		botaoOK.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				TelaSobre.this.dispose();
			}
		});
		GroupLayout gl_panel = new GroupLayout(panelPrincipal);
		gl_panel.setHorizontalGroup(
			gl_panel.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblDevCou, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
					.addContainerGap())
				.addGroup(Alignment.LEADING, gl_panel.createSequentialGroup()
					.addGap(12)
					.addComponent(txtpnCompiladorDesenvolvidoPara, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
					.addGap(8))
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap(118, Short.MAX_VALUE)
					.addComponent(botaoOK)
					.addGap(113))
		);
		gl_panel.setVerticalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblDevCou)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(txtpnCompiladorDesenvolvidoPara, GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addComponent(botaoOK)
					.addGap(13))
		);
		panelPrincipal.setLayout(gl_panel);
	}
}
